package com.jibei.mendo.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.jibei.mendo.R;
import com.jibei.mendo.event.Event;
import com.jibei.mendo.utils.Constant;
import com.jibei.mendo.utils.VibratorUtil;

/**
 * Created by lhl on 2019/9/4.
 * 预备的页面
 */
public class ReadyActivity extends BaseActivity {

    private Button btn_update_main_dev;
    private Button btn_update_sub_dev;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ready);

        initView();
    }

    private void initView() {
        btn_update_main_dev = findViewById(R.id.btn_update_main_dev);
        btn_update_sub_dev = findViewById(R.id.btn_update_sub_dev);

        final View.OnClickListener onClickListener = v -> {
            VibratorUtil.getInstance().executeVibrator(ReadyActivity.this, 100);
        };
        btn_update_main_dev.setOnClickListener(onClickListener);

        btn_update_sub_dev.setOnClickListener(onClickListener);
    }

    @Override
    public boolean onActivityReceiveEvents(Event event) {
        boolean isCaptured = false;//子Activity是否捕获事件
        if (super.onActivityReceiveEvents(event)) {
            return isCaptured;
        }
        isCaptured = true;
        switch (event.getTag()) {
            case Constant.Events.DIAN_HUO:
            case Constant.Events.JIAN_CE:
            case Constant.Events.KONG_DANG:
                finish();
                break;
            default:
                isCaptured = false;
                break;
        }
        return isCaptured;
    }
}
